

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>登入</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="./layui-minna/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="./layui-minna/minna.css" media="all">
</head>
<body>

  <div class="layminna-user-login layminna-user-display-show" id="LAY-user-login" style="display: none;">
    <div class="layminna-user-login-main">
      <div class="layminna-user-login-box layminna-user-login-header" id="login">
        <img src="./home-minna/icon.jpg" alt="MINNA Logo" width="200" height="200" style="margin: 15px auto; display: block; border-radius: 50%; border: 3px solid #fff;">
        <h2>MINNA</h2>
        <p><em>"I gona walk with you!"</em></p>
        <br>
        <p>Minna是一个开源的个人物联网平台，旨在提供一个简单易用的物联网方案。</p>
        <br>
        <p>默认账号密码:admin/admin</p>
      </div>
      <div class="layminna-user-login-box layminna-user-login-body layui-form">
        <div class="layui-form-item">
          <label class="layminna-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-usernamephone"></label>
          <input type="text" name="emailphone" id="LAY-user-login-usernamephone" lay-verify="required" placeholder="用户名" class="layui-input">
        </div>
        <div class="layui-form-item">
          <label class="layminna-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
          <input type="password" name="password" id="LAY-user-login-password" lay-verify="required" placeholder="密码" class="layui-input">
        </div>
        <div class="layui-form-item">
            <button class="layui-btn" style="background-color: #9b59b6; width: 100px; display: block; margin: 0 auto; border-radius: 4px;" lay-submit lay-filter="LAY-user-login-submit">登 入</button>
        </div>
        <div class="layui-form-item">
          <div style="margin:0 auto; text-align: center;">
            <span id="login_container"></span>
          </div>
        </div>
      </div>
    </div>
    
    <div class="layui-trans layminna-user-login-footer">
      <p>https://manykit.com © 2016-2024 <a href="" target="_blank"></a></p>
    </div>
  </div>

  <script src="./layui-minna/layui/layui.js"></script>  
  <script>

  layui.config({
    base: './layui-minna/' //静态资源所在路径
  }).extend({
    index: 'index' //主入口模块
  }).use(['index', ], function(){
    var $ = layui.$
    ,setting = layui.setting
    ,minna = layui.minna
    ,form = layui.form
    ,router = layui.router()
    ,search = router.search;

    form.render();

    form.on('submit(LAY-user-login-submit)', function(obj){    
      minna.req({
        url: setting.url +  "users/login" //实际使用请改成服务端真实接口
        ,data: obj.field
        ,done: function(res)
        {
          layui.data(setting.tableName, {
            key: setting.request.nickName
            ,value: res.data.nickname
          });

          layui.data(setting.tableName, {
            key: setting.request.tokenName
            ,value: res.data.access_token
          });
          
          layer.msg('登入成功', {
            offset: '15px'
            ,icon: 1
            ,time: 1000
          }, function(){
            location.href = 'index.html'; //后台主页
          });
        }
      });      
    });
  });

  </script>
</body>
</html>